<script type="text/javascript">
$(function(){
    $("input[name=keyword]").focus().select();
    $("select[data-edit-select]").filterSelect();
})
</script>

<!--菜单 start-->
<?php $this->load->view('defaults/common/left');?>
<!--菜单 end-->
<div id="content">
    <div class="page-header">
        <div class="container-fluid">
          <h1><?=lang('menu_yhgl')?></h1>
          <?=$this->breadcrumb->generateHTML();?>
        </div>
    </div>
    <div class="container-fluid">
        <div class="panel panel-default">
          <div class="panel-heading">
            <h3 class="panel-title"><i class="fa fa-list"></i>费用列表</h3>
          </div>
          <div class="panel-body" id="contents">
            <div class="well" style="padding:0 19px;">
              <div class="row">
                 <form action="<?=blang_url('users/CustomerPrice/')?>" method="post" name="searchform" >
                    <div class="col-sm-4">
                        <div class="form-group">
                            <label class="control-label">Name/Email/CustomerName</label>
                            <input class="form-control" type="text" name="keyword" value="<?=$keyword?>" placeholder="Name/Email/CustomerName" />
                        </div>
                        <div class="form-group">
                            <label class="control-label">Service Center</label>
                            <select class="form-control" name="site_id">
                                <option value="" >--Service Center--</option>
                                <?php foreach ($serviceCenterList as $rs):?>
                                    <option value="<?=$rs['id']?>" <?=$optServiceCenter[$rs['id']]?> > <?=$rs['name_'.$curLang]?> </option>
                                <?php endforeach;?>
                            </select>
                        </div>
                    </div>
                    <div class="col-sm-4">
                        <div class="form-group">
                            <label class="control-label">Category</label>
                            <select class="form-control" name="category_id">
                                <option value="" >--Category--</option>
                                <?php foreach ($categoryList as $rs):?>
                                    <option value="<?=$rs['id']?>" <?=$optCategory[$rs['id']]?> > <?=$rs['name_'.$curLang]?> </option>
                                <?php endforeach;?>
                            </select>
                        </div>
                        <div class="form-group">
                            <label class="control-label">Grade</label>
                            <select class="form-control" name="grade">
                                <option value="" >--Grade--</option>
                                <?php foreach ($gradeList as $rs):?>
                                    <option value="<?=$rs['id']?>" <?=$optGrade[$rs['id']]?> > <?=$rs['name_'.$curLang]?> </option>
                                <?php endforeach;?>
                            </select>
                        </div>
                    </div>
                    <div class="col-sm-4">
                        <div class="form-group">
                            <label class="control-label">Customer</label>
                             <select class="form-control" name="customer_id" data-edit-select="1">
                                <option value="" >--Customer--</option>
                                <?php foreach ($customerList as $rs):?>
                                    <option value="<?=$rs['id']?>" <?=$optCustomer[$rs['id']]?> > <?=$rs['name']?> </option>
                                <?php endforeach;?>
                            </select>
                        </div>
                        <div class="form-group">
                            <label class="control-label">Brand</label>
                            <select class="form-control" name="brand_id" data-edit-select="1">
                                <option value="" >--Brand--</option>
                                <?php foreach ($brandList as $rs):?>
                                    <option value="<?=$rs['id']?>" <?=$optBrand[$rs['id']]?> > <?=$rs['name']?> </option>
                                <?php endforeach;?>
                            </select>
                        </div>
                    </div>
                    <div class="col-sm-12">
                        <div class="form-group">
                            <input class="btn btn-primary pull-right" style="margin-bottom: 19px;" type="submit" name="searchSubmit" value="<?=lang('public_cx')?> " />
                        </div>
                    </div>
                </form>
              </div>
            </div>
            <div class="table-responsive">
                <table class="table table-bordered table-hover oms-table">
                  <thead>
                    <tr>
                        <th class="text-left">客户</th>
                        <th class="text-left">品牌</th>
                        <th class="text-left">站点</th>
                        <th class="text-left">维修项</th>
                        <th class="text-left">基础价格</th>
                        <th class="text-right">价格</th>
                        <th class="text-right">货币</th>
                        <th class="text-right">日期</th>
                        <th class="text-right">处理人</th>
                    </tr>
                  </thead>
                  <tbody>
                    <?php if($dataList): foreach ($dataList as $key=>$rs):?>
                    <tr>
                        <td class="text-left"><?=$rs['customerName']?></td>
                        <td class="text-left"><?=$rs['brandName']?></td>
                        <td class="text-left"><?=$rs['siteName']?></td>
                        <td class="text-left"><?=$rs['itemName']?></td>
                        <td class="text-left"><?=$rs['base_price']?></td>
                        <td class="text-right">
                            <span id="setPriceResult<?=$rs['id']?>"></span>
                            <input type="text" name="price" size="12" value="<?=$rs['price']?>" onblur="setLaborPrice(this,<?=$rs['id']?>,<?=$rs['price']?>)" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" />
                        </td>
                        <td class="text-right"><?=$rs['currency']?></td>
                        <td class="text-right"><?=$rs['add_time']?></td>
                        <td class="text-right"><?=$rs['add_user']?></td>
                    </tr>
                <?php endforeach; else:?>
                    <tr><td colspan="9"><?=lang('public_mygdsj')?>....</td></tr>
                <?php endif; ?>
                    
                </tbody>
                </table>
                <?php if($show_pages):?>
                <div class="page">
                    <?=$show_pages?>
                </div>
                <?php endif;?>
            </div>
          </div>
        </div>
    </div>
    <script type="text/javascript">
        function setLaborPrice(obj,id,oldPrice) {
            var newPrice = parseFloat(obj.value);
            //console.log(oldVal);
            if(newPrice == oldPrice)return false;
            $.post("<?=blang_url('common/Com_ajax/setLaborPrice')?>", {id:id,newPrice:newPrice},
                function(data){
                    if(data==1){
                        $('#setPriceResult'+id).text('OK');
                    }
                }
            );
        }
    </script>

</div>